package com.jianggy.proxy.jdk;

import java.lang.reflect.Proxy;

import com.jianggy.proxy.User;
import com.jianggy.proxy.UserDao;
import com.jianggy.proxy.UserDaoImpl;

/**
 * @author jianggy
 * @time 2018年9月24日 下午10:03:35
 * @description
 */
public class App {
	public static void main(String[] args) {
		UserDao userDao = new UserDaoImpl();
		UserDaoHandler handler = new UserDaoHandler(userDao);
		UserDao userDaoProxy = (UserDao) Proxy.newProxyInstance(userDao.getClass().getClassLoader(),
				new Class[] { UserDao.class }, handler);
		User user = new User();
		user.setId(4);
		user.setName("xx");
		user.setAddress("BJ");
		user.setSex(1);
		userDaoProxy.insertUser(user);
	}
}
